import 'package:bot_toast/bot_toast.dart';
import 'package:get/get.dart';

import '../../../services/address.dart';
import '../../../services/dio_manager.dart';
import 'my_car_model.dart';

class MyCarController extends GetxController{
  int page = 1;
  List dataArr = [];


  requestData()async{

    var params = {
      'page':page,
      'limit':10,
      'type':'',
    };
    var json = await DioManager().kkRequest(Address.oaCarsCases,params: params,method: 'get');

    MyCarModel model = MyCarModel.fromJson(json);

    if(page == 1){
      dataArr.clear();
      dataArr.addAll(model.data!);
    }else{
      if(model.data!= null){
        dataArr.addAll(model.data!);
      }else{
        BotToast.showText(text: '暂无更多');
      }
    }

    update();
  }
  onRefresh()async{
    page = 1 ;
    requestData();
  }
  onLoad()async{
    page++;
    requestData();
  }

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    requestData();
  }

}